package javaroadeditor;

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {

	public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
		super(configurer);
	}

	public ActionBarAdvisor createActionBarAdvisor(
			IActionBarConfigurer configurer) {
		return new ApplicationActionBarAdvisor(configurer);
	}

	public void preWindowOpen() {
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
		configurer.setInitialSize(new Point(400, 300));
		configurer.setShowCoolBar(true);
		configurer.setShowStatusLine(true);
	}
	
	@Override
	public void postWindowCreate() {
		super.postWindowCreate();
		// megkapja a munkafelulet ablakat
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
		Display display = configurer.getWindow().getWorkbench().getDisplay();
		// megkapja a desktop ablakat
		Shell shell = configurer.getWindow().getShell();
		Rectangle rectBounds = display.getBounds();

		int minWidth = 1000;
		int minHeight = 700;
		int x = 400;
		int y = 100;

		x = (rectBounds.width - minWidth) / 2;
		y = (rectBounds.height - minHeight) / 2;

		// a fenti szamitastol fuggoen, beallitja az ablak helyet
		shell.setBounds(x, y, minWidth, minHeight);
	}
}
